package com.sfeir.tv.client.ui.container;

import com.sfeir.tv.client.mvc.framework.AppEvent;
import com.sfeir.tv.client.mvc.framework.AppEventListener;
import com.sfeir.tv.client.mvc.framework.Model;
import com.sfeir.tv.client.ui.search.ItemModel;

public class ContainerModel extends Model {

	public ContainerModel() {
		super();
	}
	
	public void post()
	{
	    registerListeners();
	    super.post();
	}
	
	private void registerListeners()
	{
        register( AppEvent.CLICK_EVENT, new AppEventListener()
        {
            public void handleAppEvent( AppEvent event )
            {
                displayVideoInMainViewer( event );
            }
        });
	}
	
	private void displayVideoInMainViewer( AppEvent event )
	{
        ((ContainerView)view).setVideoID(((ItemModel)event.getPayload()).getVideoID());
        ((ContainerView)view).setDescription(((ItemModel)event.getPayload()).getDescription());
	}
	
}
